package reit.ass3;

import java.util.Random;




/**
 * The Class Customer.
 */
class Customer {

	/**
	 * The Enum Vandalism for type of vandalisim.
	 */
	enum  Vandalism{

		/** fixed damage . */
		FIXED , 
		/**  arbitrary damage */
		ARBITRARY, 
		/** 0.5 damage. */
		NONE;
	}
	/** if damage is not arbitrary or fixed, it is set to 0.5 as required. */
	public static final float DEFAULT_DAMAGE = 0.5f;

	/** The m name. */
	private final String mName;

	/** The m vandalism type. */
	private final Vandalism mVandalismType;

	/** The m min dmg. */
	private final float mMinDmg;

	/** The m max dmg. */
	private final float mMaxDmg;

	/**
	 * Instantiates a new customer.
	 *
	 * @param name the name
	 * @param vandalism the vandalism
	 * @param minimumDamage the minimum damage
	 * @param maximumDamage the maximum damage
	 */
	public Customer(final String name, final String vandalism, final byte minimumDamage,
			final byte maximumDamage) {
		this.mName = name;
		this.mVandalismType = getVandalismType(vandalism);
		this.mMinDmg = minimumDamage;
		this.mMaxDmg = maximumDamage;
	}

	/**
	 * Gets the vandalism type.
	 *
	 * @param vandalism the vandalism
	 * @return the vandalism type
	 */
	private Vandalism getVandalismType(final String vandalism) {
		if (vandalism.equals("Arbitrary")){
			return Vandalism.ARBITRARY;
		}
		else if (vandalism.equals("Fixed")){
			return Vandalism.FIXED;
		}
		else{
			return Vandalism.NONE;
		}
	}

	/**
	 * Gets the name.
	 *
	 * @return the name
	 */
	public String getName(){
		return mName;
	}

	/**
	 * Gets the dmg percent.
	 *
	 * @return the dmg percent
	 */
	public float getDmgPercent(){
		if (mVandalismType == Vandalism.ARBITRARY){
			Random r = new Random(); 
			return  (mMinDmg + ((mMaxDmg - mMinDmg)*r.nextFloat()));
		}
		else if (mVandalismType == Vandalism.FIXED){
			return ((mMinDmg+mMaxDmg)/2);
		}
		else{
			return  Customer.DEFAULT_DAMAGE;
		}
	}

}
